#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

int n, m;
const int N = 30;

char str[N][N];
bool st[N][N];
int dx[] = {0, -1, 0, 1}, dy[] = {1, 0, -1, 0};

int dfs(int x, int y)
{
    st[x][y] = true;
    int ret = 1;
    for (int i = 0; i < 4; ++i)
    {
        int nx = x + dx[i], ny = y + dy[i];
        if (nx >= 0 && nx < n && ny >= 0 && ny < m &&
            !st[nx][ny] && str[nx][ny] == '.')
        {
            ret += dfs(nx, ny);
        }
    }
    return ret;
}

int main()
{
    while (cin >> n >> m)
    {
        memset(st, 0, sizeof(st));
        int si, sj;
        for (int i = 0; i < n; ++i)
        {
            for (int j = 0; j < m; ++j)
            {
                cin >> str[i][j];
                if (str[i][j] == '@')
                {
                    si = i;
                    sj = j;
                }
            }
        }
        int ret = 0;
        ret = dfs(si, sj);
        cout << ret << endl;
    }
    return 0;
}